package com.shhm.common.dto.response;

import com.shhm.common.constants.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;


/**
 * @author JackZ
 * @version 1.0
 * @description: 消息响应
 * @date 2025/7/12 下午10:14
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult implements Serializable {
    private int code;
    private String msg;
    private Object data;


    /**
     * 请求成功
     */
    public static AjaxResult success() {
        return new AjaxResult(HttpStatus.SUCCESS,"操作成功!",null);
    }

    public static AjaxResult success(Object data) {
        return new AjaxResult(HttpStatus.SUCCESS,"操作成功!",data);
    }

    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(HttpStatus.SUCCESS,msg,data);
    }


    /**
     * 请求警告
     */
    public static AjaxResult warn() {
        return new AjaxResult(HttpStatus.WARN,"操作异常!",null);
    }

    public static AjaxResult warn(Object data) {
        return new AjaxResult(HttpStatus.WARN,"操作异常!",data);
    }

    public static AjaxResult warn(String msg) {
        return new AjaxResult(HttpStatus.WARN,msg,null);
    }

    public static AjaxResult warn(String msg, Object data) {
        return new AjaxResult(HttpStatus.WARN,msg,data);
    }


    /**
     * 请求错误
     */
    public static AjaxResult error() {
        return new AjaxResult(HttpStatus.ERROR,"操作异常!",null);
    }

    public static AjaxResult error(Object data) {
        return new AjaxResult(HttpStatus.ERROR,"操作异常!",data);
    }

    public static AjaxResult error(String msg) {
        return new AjaxResult(HttpStatus.ERROR,msg,null);
    }

    public static AjaxResult error(String msg, Object data) {
        return new AjaxResult(HttpStatus.ERROR,msg,data);
    }
}
